from django.shortcuts import render
from rest_framework.response import Response
from rest_framework.views import APIView
from . import models, myserializers
# Create your views here.


class New(APIView):
    def get(self, request):
        name_list = models.New.objects.all()
        name_ser = myserializers.NewSerialize(name_list, many=True)
        if name_ser:
            res = {
                'code': 200,
                'message': name_ser.data
            }
            return Response(res)
        else:
            res = {
                'code': 500,
                'message': None
            }
            return Response(res)
